/* Define to prevent recursive inclusion -------------------------------------*/
#include "main.h"
#ifndef SI2C_H
#define SI2C_H

#define IIC_ADDR 0xE2

/* Definition of GPIOI2C Pins*/
#define ESC         	0x1B
#define GPIOI2C_SCL_GPIO_PORT          GPIOA
#define GPIOI2C_SCL_PIN                GPIO_Pin_5
#define GPIOI2C_SCL_BUSCLK             RCC_AHBENR_GPIOA
#define GPIOI2C_SCL_GPIO_CLK_ENABLE()  RCC_AHBPeriphClockCmd(GPIOI2C_SCL_BUSCLK, ENABLE);

#define GPIOI2C_SDA_GPIO_PORT          GPIOA
#define GPIOI2C_SDA_PIN                GPIO_Pin_4
#define GPIOI2C_SDA_BUSCLK             RCC_AHBENR_GPIOA
#define GPIOI2C_SDA_GPIO_CLK_ENABLE()  RCC_AHBPeriphClockCmd(GPIOI2C_SDA_BUSCLK, ENABLE);

/* Exported functions --------------------------------------------------------*/

void I2C1_GPIO_Config(void);
void I2C_SetDeviceAddr(I2C_TypeDef* I2Cx, u8 deviceaddr);
void I2C_HardInit(void);
void I2C_MasterModeInit(I2C_TypeDef* I2Cx, u32 uiI2C_speed);
u8 iic_write_anyreg(unsigned char DeviceAddr, MC1081_REG RegAddr, unsigned char Data);
u8 iic_read_anyreg(unsigned char DeviceAddr, MC1081_REG RegAddr,unsigned char *pData,unsigned char size);
u8 iic_measure(uint16_t cmd,float* res);
uint8_t MY_I2C_CRC8(uint8_t data[], uint8_t nbrOfBytes);
float iic_measure_cmd(uint16_t cmd);
#endif /* SI2C_H */
